/*
  @author ayh_lscaatbear
  @create 2021年7月1日
*/
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
    if (msg.action === "updateIcon") {
        if (msg.value) {
            chrome.browserAction.setIcon({
                path : "../imgs/spend.png"
              });
        } else {
            chrome.browserAction.setIcon({
                path : "../imgs/spend_def.png"
              });
        }
    }else if(msg.action === 'getInfo'){
        chrome.tabs.getSelected(null, function (tab) {
            let tabUrl = tab.url;
            let str = /^https:\/\/www\.bilibili\.com\/video/
            let isBilibili = str.test(tabUrl)
            if(isBilibili){
                chrome.tabs.executeScript(null,{code:"getVideoInfo()"})
            }
        });
    }
});


